
#监听
# from pynput.mouse import Listener

# def on_move(x, y):
#     # 监听鼠标移动
#     print('Pointer moved to {0}'.format((x, y)))
#
# def on_click(x, y, button, pressed):
#     # 监听鼠标点击
#     print('{0} at {1}'.format('Pressed' if pressed else 'Released', (x, y)))
#     if not pressed:
#         # Stop listener
#         return False
#
# def on_scroll(x, y, dx, dy):
#     # 监听鼠标滚轮
#     print('Scrolled {0}'.format((x, y)))
#
# # 连接事件以及释放
# with Listener(on_move=on_move, on_click=on_click, on_scroll=on_scroll) as listener:
#     listener.join()


###鼠标控制
# from pynput.mouse import Button, Controller
#
# mouse = Controller()

# Read pointer position
# print('The current pointer position is {0}'.format(
#     mouse.position))

# Set pointer position
# mouse.position = (1011, 20)
# print('Now we have moved it to {0}'.format(
#     mouse.position))
#
# Move pointer relative to current position
# mouse.move(5, -5)

# Press and release
# mouse.press(Button.left)
# mouse.release(Button.left)

# Double click; this is different from pressing and releasing
# twice on macOS
# mouse.click(Button.left, 2)

# Scroll two steps down
# mouse.scroll(0, -21)


# #鼠标监听demo
# from pynput import mouse
#
# def on_move(x, y):
#     print('Pointer moved to {0}'.format(
#         (x, y)))
#
# def on_click(x, y, button, pressed):
#     print('{0} at {1}'.format(
#         'Pressed' if pressed else 'Released',
#         (x, y)))
#     if not pressed:
#         # Stop listener
#         return False
#
# def on_scroll(x, y, dx, dy):
#     print('Scrolled {0} at {1}'.format(
#         'down' if dy < 0 else 'up',
#         (x, y)))
#
# # Collect events until released
# with mouse.Listener(
#         on_move=on_move,
#         on_click=on_click,
#         on_scroll=on_scroll) as listener:
#     listener.join()
#
# # ...or, in a non-blocking fashion:
# listener = mouse.Listener(
#     on_move=on_move,
#     on_click=on_click,
#     on_scroll=on_scroll)
# listener.start()

# from pynput import mouse
#
# # The event listener will be running in this block
# with mouse.Events() as events:
#     # Block at most one second
#     event = events.get(5.0)
#     if event is None:
#         print('You did not interact with the mouse within one second')
#     else:
#         print('Received event {}'.format(event))